package org.hgvc.webapp.ets.jsf.beans.admin;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

import javax.faces.component.UIParameter;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;

import org.hgvc.webapp.ets.bo.Agreement;
import org.hgvc.webapp.ets.bo.Member;
import org.hgvc.webapp.ets.bo.MemberComp;
import org.hgvc.webapp.ets.bo.MemberInd;
import org.hgvc.webapp.ets.bo.Partner;
import org.hgvc.webapp.ets.bo.PartnerProduct;
import org.hgvc.webapp.ets.bo.RCIAssignment;
import org.hgvc.webapp.ets.bo.RCIAssignmentDetail;
import org.hgvc.webapp.ets.bo.RCIBooking;
import org.hgvc.webapp.ets.bo.RCIBookingEntry;
import org.hgvc.webapp.ets.bo.RCIBulkBank;
import org.hgvc.webapp.ets.bo.RCIIncomingMember;
import org.hgvc.webapp.ets.bo.RCIMember;
import org.hgvc.webapp.ets.bo.RCISplitWeekConfig;
import org.hgvc.webapp.ets.constant.AdminConstant;
import org.hgvc.webapp.ets.constant.BookingConstant;
import org.hgvc.webapp.ets.constant.CommonConstant;
import org.hgvc.webapp.ets.spring.service.AdminRCIService;
import org.hgvc.webapp.ets.spring.service.MemberService;
import org.hgvc.webapp.ets.spring.service.PartnerService;
import org.jocsb.base.AbstractBean;
import org.jocsb.base.exception.BaseException;
import org.jocsb.base.util.DateUtil;
import org.jocsb.base.util.SpringUtils;


public class AdminRCIBean extends AbstractBean{
	public static final String BEAN_NAME="adminRCIBean";
	
	public static final String AB_ACTION_INVOKE="navRCIBookingEntryApprovalAction";
	public static final String NAV_VIEW_RCI_BOOKING_ENTRY="viewRCIBookingEntry";
	
	private AdminRCIService adminRCIService;
	private PartnerService partnerService;
	private MemberService memberService;
	//-----Common----------------------------
	private List<SelectItem> selectSearchList;
	private String searchField;
	private String searchKeyword;
	private boolean catchError;
	private boolean lookupForm;
	//---------------------------------------
	//---RCI Bulk Bank-----------------------
	private List<SelectItem> selectPartnerList;
	private List<SelectItem> selectProductList;
	private List<RCIBulkBank> rciBulkBankList;
	
	private RCIBulkBank rciBulkBank;
	private Partner partner;
	private PartnerProduct partnerProduct;
	//---------------------------------------------
	//-------RCI Member----------------------------
	private List<SelectItem> selectMemberList;
	private List<SelectItem> selectAgreementList;
	private List<RCIMember> rciMemberList;
	private RCIMember rciMember;
	private Member member;
	private Agreement agreement;
	private List<Agreement> agreementList; 
	//---------------------------------------------
	//------RCI Assignment-------------------------
	private List<SelectItem> selectRCIMemberList;
	private List<SelectItem> selectRCIBulkBankList;
	private List<RCIAssignment> rciAssignmentList;
	private List<RCIAssignmentDetail> rciAssignmentDetailList;
	private RCIAssignment rciAssignment;
	private RCIAssignmentDetail rciAssignmentDetail;
	//---------------------------------------------
	
	private List<RCIBooking> rciBookiingList;
	private boolean externalMember;
	
	
	//-----Added by Jacky 19-Nov-2008 1355--------//
	private RCIIncomingMember rciIncomingMember;
	private List<RCIIncomingMember> rciIncomingMemberList;
	private List<RCIIncomingMember> rciIncomingMemberDeleteList;
	
	public RCIIncomingMember getRciIncomingMember() {
		return rciIncomingMember;
	}
	public void setRciIncomingMember(RCIIncomingMember rciIncomingMember) {
		this.rciIncomingMember = rciIncomingMember;
	}
	public List<RCIIncomingMember> getRciIncomingMemberList() {
		return rciIncomingMemberList;
	}
	//---------------------------------------------//
	
	public boolean isExternalMember() {
		return externalMember;
	}
	public void setExternalMember(boolean externalMember) {
		this.externalMember = externalMember;
	}
	public List<RCIBooking> getRciBookiingList() {
		return rciBookiingList;
	}
	public String getSearchField() {
		return searchField;
	}
	public void setSearchField(String searchField) {
		this.searchField = searchField;
	}
	public String getSearchKeyword() {
		return searchKeyword;
	}
	public void setSearchKeyword(String searchKeyword) {
		this.searchKeyword = searchKeyword;
	}
	public RCIBulkBank getRciBulkBank() {
		return rciBulkBank;
	}
	public void setRciBulkBank(RCIBulkBank rciBulkBank) {
		this.rciBulkBank = rciBulkBank;
	}
	public Partner getPartner() {
		return partner;
	}
	public void setPartner(Partner partner) {
		this.partner = partner;
	}
	public PartnerProduct getPartnerProduct() {
		return partnerProduct;
	}
	public void setPartnerProduct(PartnerProduct partnerProduct) {
		this.partnerProduct = partnerProduct;
	}
	
	public List<SelectItem> getSelectPartnerList() {
		return selectPartnerList;
	}
	public List<SelectItem> getSelectSearchList() {
		return selectSearchList;
	}
	
	public List<SelectItem> getSelectProductList() {
		try{
			if (partner.getPartnerId()!=null){
				selectProductList=new ArrayList<SelectItem>();
				List<PartnerProduct> list=this.partnerService.getPartnerProductList(this.partner);
				for (PartnerProduct partnerProduct : list){
					SelectItem selectItem=new SelectItem(partnerProduct.getPartnerProductId(),partnerProduct.getCode()+" - "+partnerProduct.getDesc());
					selectProductList.add(selectItem);
				}
			}
		}catch(BaseException be){
			initErrorBean(be);
		}
		
		return selectProductList;
	}

	public void setAdminRCIService(AdminRCIService adminRCIService) {
		this.adminRCIService = adminRCIService;
	}

	public void setPartnerService(PartnerService partnerService) {
		this.partnerService = partnerService;
	}
	
	public String initRCIBulkBankAction(){
		this.catchError=false;
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		
		try{
			this.partner=new Partner();
			this.partnerProduct=new PartnerProduct();
			this.rciBulkBank=new RCIBulkBank();
			this.selectPartnerList=new ArrayList<SelectItem>();
			this.selectProductList=new ArrayList<SelectItem>();
			
			List<Partner> partnerList=this.partnerService.getApprovedPartnerList();
			
			for(Partner partnerL : partnerList){
				SelectItem selectItem=new SelectItem(partnerL.getPartnerId(),partnerL.getCode()+" - "+ partnerL.getCompName());
				selectPartnerList.add(selectItem);
			}
			
			this.rciBulkBankList=this.adminRCIService.getRCIBulkBankList();
			
			this.selectSearchList=new ArrayList<SelectItem>();
			SelectItem selectItemYear=new SelectItem(AdminConstant.SEARCH_YEAR,AdminConstant.SEARCH_YEAR);
			this.selectSearchList.add(selectItemYear);
			SelectItem selectItemPartner=new SelectItem(AdminConstant.SEARCH_PARTNER_CODE,AdminConstant.SEARCH_PARTNER_CODE);
			this.selectSearchList.add(selectItemPartner);
			SelectItem selectItemProduct=new SelectItem(AdminConstant.SEARCH_PRODUCT_CODE,AdminConstant.SEARCH_PRODUCT_CODE);
			this.selectSearchList.add(selectItemProduct);
			
			this.searchField=AdminConstant.SEARCH_YEAR;
		}catch(Exception ex){
			ex.printStackTrace();
			this.catchError=true;
		}
		
		return outcome;
	}
	
	public String navAddRCIBulkBankAction(){
		return navCommonOutcome(true);
	}
	public void navAddRCIBulkBankActionEvent(ActionEvent event){
		this.rciBulkBank=new RCIBulkBank();
		this.partner=new Partner();
		this.partnerProduct=new PartnerProduct();
	}
	
	public String addRCIBulkBankAction(){
		return navCommonOutcome(true);
	}
	public void addRCIBulkBankActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			GregorianCalendar gc=new GregorianCalendar();
			gc.setTime(this.rciBulkBank.getEffectiveDate());
			int week=gc.get(GregorianCalendar.WEEK_OF_YEAR);
			this.rciBulkBank.setWeek(week);
			this.rciBulkBank.setPartnerProduct(this.partnerProduct);
			this.rciBulkBank.setCreatedBy(getThisUser());
			this.rciBulkBank.setCreatedDate(new Date());
			this.rciBulkBank.setIsDeleted(CommonConstant.NOT_DELETED);
			this.rciBulkBank.setExpiryDate(this.rciBulkBank.getEffectiveDate());
			this.rciBulkBank.setAvailableFlag(new Integer(0));
			this.adminRCIService.saveRCIBulkBank(this.rciBulkBank);
			
			this.rciBulkBankList=this.adminRCIService.getRCIBulkBankList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navUpdateRCIBulkBankAction(){
		return navCommonOutcome(true);
	}
	public void navUpdateRCIBulkBankActionEvent(ActionEvent event){
		UIParameter param=(UIParameter)event.getComponent().findComponent("rciBulkBankId");
		String rciBulkBankId = param.getValue().toString();
		for(RCIBulkBank rciBulkBankP : this.rciBulkBankList){
			if (rciBulkBankP.getRciBulkBankId().equalsIgnoreCase(rciBulkBankId)){
				this.rciBulkBank=rciBulkBankP;
				
				this.partner=this.rciBulkBank.getPartnerProduct().getPartner();
				this.partnerProduct=this.rciBulkBank.getPartnerProduct();
				break;
			}
		}
	}
	
	public String updateRCIBulkBankAction(){
		return navCommonOutcome(true);
	}
	public void updateRCIBulkBankActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			GregorianCalendar gc=new GregorianCalendar();
			gc.setTime(this.rciBulkBank.getEffectiveDate());
			int week=gc.get(GregorianCalendar.WEEK_OF_YEAR);
			this.rciBulkBank.setWeek(week);
			this.rciBulkBank.setPartnerProduct(this.partnerProduct);
			this.rciBulkBank.setModifiedBy(getThisUser());
			this.rciBulkBank.setModifiedDate(new Date());
			this.adminRCIService.updateRCIBulkBank(this.rciBulkBank);
			
			this.rciBulkBankList=this.adminRCIService.getRCIBulkBankList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public List<RCIBulkBank> getRciBulkBankList() {
		return rciBulkBankList;
	}
	
	public String deleteRCIBulkBankAction(){
		return navCommonOutcome(true);
	}
	public void deleteRCIBulkBankActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			List<RCIBulkBank> deleteList=new ArrayList<RCIBulkBank>();
			for(RCIBulkBank rciBulkBank : this.rciBulkBankList){
				if (rciBulkBank.isMarkAsSelect())
					deleteList.add(rciBulkBank);
			}
			this.adminRCIService.deleteRCIBulkBank(deleteList);
			this.rciBulkBankList=this.adminRCIService.getRCIBulkBankList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String searchRCIBulkBankAction(){
		return navCommonOutcome(true);
	}
	public void searchRCIBulkBankActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.rciBulkBankList = this.adminRCIService.getRCILBulkBankList(searchField, this.searchKeyword);
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	//---------RCI Bulk bank -end-----------------------------------------------
	//---------RCI Member-------------------------------------------------------
	public RCIMember getRciMember() {
		return rciMember;
	}
	public void setRciMember(RCIMember rciMember) {
		this.rciMember = rciMember;
	}
	public Member getMember() {
		return member;
	}
	public void setMember(Member member) {
		this.member = member;
	}
	public Agreement getAgreement() {
		if (this.agreement.getAgreementId()!=null){
			if (this.agreement.getAgreementId().length()>0){
				for(Agreement agreementP : this.agreementList){
					if (agreementP.getAgreementId().equalsIgnoreCase(this.agreement.getAgreementId())){
						this.agreement=agreementP;
						break;
					}
				}
			}	
		}
		return agreement;
	}
	public void setAgreement(Agreement agreement) {
		this.agreement = agreement;
	}
	public List<SelectItem> getSelectMemberList() {
		return selectMemberList;
	}
	public List<SelectItem> getSelectAgreementList() {
		
		try{
			if (member.getMemberId()!=null){
				if (member.getMemberId().length()>0){
					this.agreementList =this.memberService.getAgreementListByMemberId(member.getMemberId());
					selectAgreementList=new ArrayList<SelectItem>();
					for(Agreement agreementP : agreementList){
						SelectItem selectItem=new SelectItem(agreementP.getAgreementId(),agreementP.getAgreetmentNo());
						selectAgreementList.add(selectItem);
					}
				}	
			}
		}catch(BaseException be){
			initErrorBean(be);
		}
		return selectAgreementList;
	}
	public List<RCIMember> getRciMemberList() {
		return rciMemberList;
	}
	
	public void setMemberService(MemberService memberService) {
		this.memberService = memberService;
	}
	
	public String initRCIMemberAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		
		try{
			this.rciMember=new RCIMember();
			this.member=new Member();
			this.agreement=new Agreement();
			this.selectMemberList=new ArrayList<SelectItem>();
			this.selectAgreementList=new ArrayList<SelectItem>();
			List<Member> memberList=memberService.getMemberActiveList();
			for (Member memberP : memberList){
				String memberName = "";
				if (memberP.getMemberType().equalsIgnoreCase(CommonConstant.MEMBER_TYPE_IND)){
				   MemberInd memberInd = this.memberService.getMemberIndByMemberId(memberP.getMemberId());
				   if (memberInd!=null)
					   memberName = memberInd.getNameAsIcPassport();
				}else{
				   MemberComp memberComp = this.memberService.getMemberCompByMemberId(memberP.getMemberId());
				   if (memberComp!=null)
					   memberName = memberComp.getCompName();
				}
				
				SelectItem selectItem=new SelectItem(memberP.getMemberId(),memberName);
				selectMemberList.add(selectItem);
			}
			this.searchField=AdminConstant.SEARCH_AGREEMENT_NO;
			this.selectSearchList=new ArrayList<SelectItem>();
			SelectItem search1=new SelectItem(AdminConstant.SEARCH_AGREEMENT_NO,AdminConstant.SEARCH_AGREEMENT_NO);
			this.selectSearchList.add(search1);
			SelectItem search2=new SelectItem(AdminConstant.SEARCH_MEMBERSHIP_NO,AdminConstant.SEARCH_MEMBERSHIP_NO);
			this.selectSearchList.add(search2);
			SelectItem search3=new SelectItem(AdminConstant.SEARCH_RCI_NO,AdminConstant.SEARCH_RCI_NO);
			this.selectSearchList.add(search3);
			
			this.rciMemberList=this.adminRCIService.getRCIMemberList();
		}catch(BaseException be){
			initErrorBean(be);
		}
		return outcome;
	}
	
	public String navAddRCIMemberAction(){
		return navCommonOutcome(true);
	}
	public void navAddRCIMemberActionEvent(ActionEvent event){
		this.catchError=false;
		this.rciMember=new RCIMember();
		this.member=new Member();
		this.agreement=new Agreement();
	}
	public void externalFlagActionEvent(ActionEvent event){
		System.out.println("TEST");
	}
	public String addRCIMemberAction(){
		return navCommonOutcome(true);
	}
	public void addRCIMemberActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			
			
			//if (externalMember)
			//	this.rciMember.setExternalFlag(new Integer(1));
			//else
				this.rciMember.setExternalFlag(new Integer(0));
			
			//if (!externalMember){
				Member memberPP = this.memberService.getMemberById(this.member.getMemberId());
				
				String memberName = "";
				String memberNo="";
				if (memberPP.getMemberType().equalsIgnoreCase(CommonConstant.MEMBER_TYPE_IND)){
				   MemberInd memberInd = this.memberService.getMemberIndByMemberId(memberPP.getMemberId());
				   if (memberInd!=null){
					   memberName = memberInd.getNameAsIcPassport();
					   memberNo =memberInd.getNewIcNo();
				   }
				}else{
				   MemberComp memberComp = this.memberService.getMemberCompByMemberId(memberPP.getMemberId());
				   if (memberComp!=null){
					   memberName = memberComp.getCompName();
					   memberNo = memberComp.getCompNo();
				   }
				}
				
				this.rciMember.setRciMemberName(memberName);
				this.rciMember.setRciMemberIcNo(memberNo);
			//}
			this.rciMember.setAgreement(this.agreement);
			this.rciMember.setFullMembershipPrice(this.agreement.getFullMembershipPrice());
			this.rciMember.setMember(this.member);
			this.rciMember.setCreatedBy(getThisUser());
			this.rciMember.setCreatedDate(new Date());
			this.rciMember.setIsDeleted(CommonConstant.NOT_DELETED);
			
			validationRCIMember();
			
			this.adminRCIService.saveRCIMember(this.rciMember);
			this.rciMemberList=this.adminRCIService.getRCIMemberList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	public String navUpdateRCIMemberAction(){
		return navCommonOutcome(true);
	}
	public void navUpdateRCIMemberActionEvent(ActionEvent event){
		this.catchError=false;
		UIParameter param=(UIParameter)event.getComponent().findComponent("rciMemberId");
		String rciMemberId=param.getValue().toString();
		for(RCIMember rciMemberP : this.rciMemberList){
			if (rciMemberP.getRciMemberId().equalsIgnoreCase(rciMemberId)){
				this.rciMember=rciMemberP;
				this.member=this.rciMember.getMember();
				this.agreement=this.rciMember.getAgreement();
				
				Integer flag = rciMemberP.getExternalFlag();
				if (flag==null) flag=0;
				if (flag>0)
					this.externalMember=true;
				else
					this.externalMember=false;
				
				break;
			}
		}
	}
	public String updateRCIMemberAction(){
		return navCommonOutcome(true);
	}
	public void updateRCIMemberActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			
			validationRCIMember();
			
			if (externalMember)
				this.rciMember.setExternalFlag(new Integer(1));
			else
				this.rciMember.setExternalFlag(new Integer(0));
			
			if (!externalMember){
				Member memberPP = this.memberService.getMemberById(this.member.getMemberId());
				
				String memberName = "";
				String memberNo="";
				if (memberPP.getMemberType().equalsIgnoreCase(CommonConstant.MEMBER_TYPE_IND)){
				   MemberInd memberInd = this.memberService.getMemberIndByMemberId(memberPP.getMemberId());
				   if (memberInd!=null){
					   memberName = memberInd.getNameAsIcPassport();
					   memberNo =memberInd.getNewIcNo();
				   }
				}else{
				   MemberComp memberComp = this.memberService.getMemberCompByMemberId(memberPP.getMemberId());
				   if (memberComp!=null){
					   memberName = memberComp.getCompName();
					   memberNo = memberComp.getCompNo();
				   }
				}
				
				this.rciMember.setRciMemberName(memberName);
				this.rciMember.setRciMemberIcNo(memberNo);
			}
			
			this.rciMember.setAgreement(this.agreement);
			this.rciMember.setMember(this.member);
			this.rciMember.setCreatedBy(getThisUser());
			this.rciMember.setCreatedDate(new Date());
			this.rciMember.setIsDeleted(CommonConstant.NOT_DELETED);
			this.adminRCIService.updateRCIMember(this.rciMember);
			this.rciMemberList=this.adminRCIService.getRCIMemberList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	public String deleteRCIMemberAction(){
		return navCommonOutcome(true);
	}
	public void deleteRCIMemberActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			List<RCIMember> deleteList=new ArrayList<RCIMember>();
			for (RCIMember rciMemberP : this.rciMemberList){
				if (rciMemberP.isMarkAsSelect())
					deleteList.add(rciMemberP);
			}
			this.adminRCIService.deleteRCIMember(deleteList);
			this.rciMemberList=this.adminRCIService.getRCIMemberList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	public String searchRCIMemberAction(){
		return navCommonOutcome(true);
	}
	public void searchRCIMemberActionEvent(ActionEvent event){
		
	}
	//-----------RCI Member -End-----------------------------------------------
	//-----------RCI Assignment -Start-----------------------------------------------
	public RCIAssignment getRciAssignment() {
		return rciAssignment;
	}
	public void setRciAssignment(RCIAssignment rciAssignment) {
		this.rciAssignment = rciAssignment;
	}
	public RCIAssignmentDetail getRciAssignmentDetail() {
		return rciAssignmentDetail;
	}
	public void setRciAssignmentDetail(RCIAssignmentDetail rciAssignmentDetail) {
		this.rciAssignmentDetail = rciAssignmentDetail;
	}
	public List<SelectItem> getSelectRCIMemberList() {
		return selectRCIMemberList;
	}
	public List<SelectItem> getSelectRCIBulkBankList() {
		return selectRCIBulkBankList;
	}
	public List<RCIAssignment> getRciAssignmentList() {
		return rciAssignmentList;
	}
	public List<RCIAssignmentDetail> getRciAssignmentDetailList() {
		return rciAssignmentDetailList;
	}
	
	public String initRCIAssignmentAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		
		try{
			//this.selectRCIMemberList=new ArrayList<SelectItem>();
			this.rciMemberList=this.adminRCIService.getRCIMemberList();
			/*for(RCIMember rciMemberP : this.rciMemberList){
				SelectItem selectItem=new SelectItem(rciMemberP.getRciMemberId(),rciMemberP.getRciNo());
				this.selectRCIMemberList.add(selectItem);
			}*/
			this.selectRCIBulkBankList=new ArrayList<SelectItem>();
			this.rciBulkBankList=this.adminRCIService.getRCIBulkBankList();
			
			for(RCIBulkBank rciBulkBankP : this.rciBulkBankList){
				SelectItem selectItem=new SelectItem(rciBulkBankP.getRciBulkBankId(),
						"[Product Code - "+rciBulkBankP.getPartnerProduct().getCode()+"] "
						+" : [Room 1 No. - "+rciBulkBankP.getRoom1No()+"]"
						+" : [Room 2 No. - "+rciBulkBankP.getRoom2No()+"]");
				this.selectRCIBulkBankList.add(selectItem);
			}
			this.rciMember=new RCIMember();
			this.rciAssignment=new RCIAssignment();
			this.rciAssignmentDetail=new RCIAssignmentDetail();
			this.rciAssignmentList=this.adminRCIService.getRCIAssignmentList();
			this.rciAssignmentDetailList=new ArrayList<RCIAssignmentDetail>();
			this.selectSearchList=new ArrayList<SelectItem>();
			SelectItem selectItem=new SelectItem(AdminConstant.SEARCH_RCI_NO,AdminConstant.SEARCH_RCI_NO);
			this.selectSearchList.add(selectItem);
			this.searchField=AdminConstant.SEARCH_RCI_NO;
		}catch(BaseException be){
			initErrorBean(be);
			outcome=null;
		}
		return outcome;
	}
	
	public String navAddRCIAssignmentAction(){
		return navCommonOutcome(true);
	}
	public void navAddRCIAssignmentActionEvent(ActionEvent event){
		this.catchError=false;
		this.rciMember=new RCIMember(); 
		this.rciAssignment=new RCIAssignment();
		this.rciAssignmentDetailList=new ArrayList<RCIAssignmentDetail>();
	}
	public String addRCIAssignmentAction(){
		return navCommonOutcome(true);
	}
	public void addRCIAssignmentActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.rciAssignment.setRciMember(this.rciMember);
			this.rciAssignment.setCreatedBy(getThisUser());
			this.rciAssignment.setCreatedDate(new Date());
			this.rciAssignment.setIsDeleted(CommonConstant.NOT_DELETED);
			RCIAssignment rciAssignmentP = this.adminRCIService.saveRCIAssignment(this.rciAssignment);
			this.rciAssignment=rciAssignmentP;
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	public String navUpdateRCIAssignmentAction(){
		return navCommonOutcome(true);
	}
	public void navUpdateRCIAssignmentActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			UIParameter param = (UIParameter)event.getComponent().findComponent("rciAssignmentId");
			String rciAssignmentId = param.getValue().toString();
			
			for (RCIAssignment rciAssignmentP : this.rciAssignmentList){
				if (rciAssignmentP.getRciAssignmentId().equalsIgnoreCase(rciAssignmentId)){
					this.rciAssignment=rciAssignmentP;
					this.rciAssignmentDetailList=this.adminRCIService.getRCIAssignmentDetailList(rciAssignmentP);
					break;
				}
			}
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	public String navAddRCIAssignmentDetailAction(){
		return navCommonOutcome(true);
	}
	public void navAddRCIAssignmentDetailActionEvent(ActionEvent event){
		this.rciAssignmentDetail=new RCIAssignmentDetail();
		this.rciBulkBank=new RCIBulkBank();
	}
	public String addRCIAssignmentDetailAction(){
		return navCommonOutcome(true);
	}
	public void addRCIAssignmentDetailActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.rciAssignmentDetail.setRciAssignment(this.rciAssignment);
			this.rciAssignmentDetail.setRciBulkBank(this.rciBulkBank);
			this.rciAssignmentDetail.setIsDeleted(CommonConstant.NOT_DELETED);
			this.rciAssignmentDetail.setCreatedBy(getThisUser());
			this.rciAssignmentDetail.setCreatedDate(new Date());
			this.adminRCIService.saveRCIAssignmentDetail(this.rciAssignment, this.rciAssignmentDetail);
			this.rciAssignmentDetailList=this.adminRCIService.getRCIAssignmentDetailList(this.rciAssignment);
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	public String deleteRCIAssignmentAction(){
		return navCommonOutcome(true);
	}
	public void deleteRCIAssignmentActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			List<RCIAssignment> deleteList=new ArrayList<RCIAssignment>();
			for (RCIAssignment rciAssignmentP : this.rciAssignmentList){
				if (rciAssignmentP.isMarkAsSelect()){
					deleteList.add(rciAssignmentP);
				}
			}
			this.adminRCIService.removeRCIAssignment(deleteList);
			this.rciAssignmentList=this.adminRCIService.getRCIAssignmentList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String deleteRCIAssignmentDetailAction(){
		return navCommonOutcome(true);
	}
	public void deleteRCIAssignmentDetailActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			List<RCIAssignmentDetail> deleteList=new ArrayList<RCIAssignmentDetail>();
			for(RCIAssignmentDetail rciAssignmentDetailP : this.rciAssignmentDetailList){
				if (rciAssignmentDetailP.isMarkAsSelect()){
					deleteList.add(rciAssignmentDetailP);
				}
			}
			this.adminRCIService.removeRCIAssignmentDetail(deleteList);
			this.rciAssignmentList=this.adminRCIService.getRCIAssignmentList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String searchRCIAssignmentAction(){
		return navCommonOutcome(true);
	}
	public void searchRCIAssignmentActionEvent(ActionEvent event){
		
	}
	
	public boolean isLookupForm() {
		return lookupForm;
	}
	
	public void lookupFormActionEvent(ActionEvent event){
		this.lookupForm=true;
	}
	public void lookupFormSelectedActionEvent(ActionEvent event){
		this.lookupForm=false;
		UIParameter param=(UIParameter)event.getComponent().findComponent("rciMemberId");
		String rciMemberId=param.getValue().toString();
		for(RCIMember rciMemberP : this.rciMemberList){
			if (rciMemberP.getRciMemberId().equalsIgnoreCase(rciMemberId)){
				this.rciMember=rciMemberP;
				break;
			}
		}
	}
	public void lookupFormCloseActionEvent(ActionEvent event){
		this.lookupForm=false;
	}
	//-----------RCI Assignment -End-----------------------------------------------
	
	public String viewRCIOutgoingAction(){
		return navCommonOutcome(true);
	}
	public String viewRCIIncomingAction(){
		return navCommonOutcome(true);
	}
	public void viewRCIOutgoingActionEvent(ActionEvent event){
		this.catchError=false;
		UIParameter param=(UIParameter)event.getComponent().findComponent("rciBulkBankId");
		String rciBulkBankId = param.getValue().toString();
		for(RCIBulkBank rciBulkBank : this.rciBulkBankList){
			if (rciBulkBank.getRciBulkBankId().equalsIgnoreCase(rciBulkBankId)){
				this.rciBulkBank=rciBulkBank;
				break;
			}
		}
	
		try{
			this.rciAssignmentList = this.adminRCIService.getRCIAssignmentList(this.rciBulkBank);	
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public void viewRCIIncomingActionEvent(ActionEvent event){
		this.catchError=false;
		UIParameter param=(UIParameter)event.getComponent().findComponent("rciBulkBankId");
		String rciBulkBankId = param.getValue().toString();
		for(RCIBulkBank rciBulkBank : this.rciBulkBankList){
			if (rciBulkBank.getRciBulkBankId().equalsIgnoreCase(rciBulkBankId)){
				this.rciBulkBank=rciBulkBank;
				break;
			}
		}
	
		try{
			this.rciBookiingList = this.adminRCIService.getRCIBookingList(this.rciBulkBank);	
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public void validationRCIMember()throws BaseException{
		//if (externalMember){
		//	if (this.rciMember.getRciMemberName()==null||this.rciMember.getRciMemberIcNo()==null)
		//		throw new BaseException(SpringUtils.getMessage("error.required",new Object[]{}));
		//}else{
			if (this.rciMember.getMember()==null || this.rciMember.getAgreement()==null){
		//		System.out.println("is null 1");
				throw new BaseException(SpringUtils.getMessage("error.required",new Object[]{}));
			}
		//}
		
		if (this.rciMember.getRciNo()==null	|| this.rciMember.getEnrollmentDate()==null ||
			this.rciMember.getEnrollmentAmount()==null || this.rciMember.getEffectiveDate()==null ||
			this.rciMember.getExpiryDate()==null){
		//	System.out.println("is null 2");
			throw new BaseException(SpringUtils.getMessage("error.required",new Object[]{}));
		}
	}
	
	
	//-----Added by Jacky 19-Nov-2008 1359-----
	//-----RCI Incoming Member Module-----------
	public String initRCIIncomingMemberAction(){
		return navCommonOutcome(false);
	}
	public void initRCIIncomingMemberActionListener(ActionEvent event){
		try{
			this.rciIncomingMemberList=this.adminRCIService.getRCIIncomingMemberList();
		}catch(BaseException be){
			initErrorBean(be);
		}
	}
	
	public String navAddRCIIncomingMemberAction(){
		return navCommonOutcome(false);
	}
	public void navAddRCIIncomingMemberActionListener(ActionEvent event){
		this.rciIncomingMember=new RCIIncomingMember();
	}

	public String addRCIIncomingMemberAction(){
		return navCommonOutcome(true);
	}
	public void addRCIIncomingMemberActionListener(ActionEvent event){
		this.catchError=false;
		try{
			this.rciIncomingMember.setCreatedBy(getThisUser());
			this.rciIncomingMember.setCreatedDate(new Date());
			this.rciIncomingMember.setIsDeleted(CommonConstant.NOT_DELETED);
			this.adminRCIService.saveRCIIncomingMember(rciIncomingMember);
			this.rciIncomingMemberList=this.adminRCIService.getRCIIncomingMemberList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navUpdateRCIIncomingMemberAction(){
		return navCommonOutcome(false);
	}
	public void navUpdateRCIIncomingMemberActionListener(ActionEvent event){
		UIParameter param=(UIParameter)event.getComponent().findComponent("rciIncomingMemberId");
		String rciIncomingMemberId = param.getValue().toString();
		
		for (RCIIncomingMember rciIncomingMemberP : this.rciIncomingMemberList){
			if (rciIncomingMemberP.getRciIncomingMemberId().equalsIgnoreCase(rciIncomingMemberId)){
				this.rciIncomingMember = rciIncomingMemberP;
				break;
			}
		}
	}
	
	public String updateRCIIncomingMemberAction(){
		return navCommonOutcome(true);
	}
	public void updateRCIIncomingMemberActionListener(ActionEvent event){
		this.catchError=false;
		try{
			rciIncomingMember.setModifiedBy(getThisUser());
			rciIncomingMember.setModifiedDate(new Date());
			this.adminRCIService.updateRCIIncomingMember(rciIncomingMember);
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String deleteRCIIncomingMemberAction(){
		return navCommonOutcome(true);
	}
	public void deleteRCIIncomingMemberActionListener(ActionEvent event){
		
	}
	
	//---------Common Navigation Outcome--------------------------------------------//
	private String navCommonOutcome(boolean catchErrorOutcome){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		
		if (catchErrorOutcome){
			if (this.catchError)
				outcome=null;
			
			this.catchError=false;
		}
		return outcome;
	}
	//---------------------------------------------------------------------------------//
	
	//----------RCI Split Week Config Maintenance -----------------------//
	private RCISplitWeekConfig rciSplitWeekConfig;
	private List<RCISplitWeekConfig> rciSplitWeekConfigList;
	private List<RCISplitWeekConfig> rciSplitWeekConfigDeleteList;
	private List<SelectItem> selectDays;

	
	public List<SelectItem> getSelectDays() {
		return selectDays;
	}
	public RCISplitWeekConfig getRciSplitWeekConfig() {
		return rciSplitWeekConfig;
	}
	public void setRciSplitWeekConfig(RCISplitWeekConfig rciSplitWeekConfig) {
		this.rciSplitWeekConfig = rciSplitWeekConfig;
	}
	public List<RCISplitWeekConfig> getRciSplitWeekConfigList() {
		return rciSplitWeekConfigList;
	}
	public List<RCISplitWeekConfig> getRciSplitWeekConfigDeleteList() {
		return rciSplitWeekConfigDeleteList;
	}
		//***Launch list****
	public String initRCISplitWeekConfigAction(){
		return navCommonOutcome(false);
	}
	public void initRCISplitWeekConfigActionListener(ActionEvent event){
		try{
			this.rciSplitWeekConfigList=this.adminRCIService.getRCISplitWeekConfigList();
			
			this.selectDays=new ArrayList<SelectItem>();
			this.selectDays.add(new SelectItem(Calendar.SUNDAY,DateUtil.DAY_SUN));
			this.selectDays.add(new SelectItem(Calendar.MONDAY,DateUtil.DAY_MON));
			this.selectDays.add(new SelectItem(Calendar.TUESDAY,DateUtil.DAY_TUE));
			this.selectDays.add(new SelectItem(Calendar.WEDNESDAY,DateUtil.DAY_WED));
			this.selectDays.add(new SelectItem(Calendar.THURSDAY,DateUtil.DAY_THU));
			this.selectDays.add(new SelectItem(Calendar.FRIDAY,DateUtil.DAY_FRI));
			this.selectDays.add(new SelectItem(Calendar.SATURDAY,DateUtil.DAY_SAT));
		}catch(BaseException be){
			initErrorBean(be);
		}
	}
	
	public String navAddRCISplitWeekConfigAction(){
		return navCommonOutcome(false);
	}
	public void navAddRCISplitWeekConfigActionListener(ActionEvent event){
		this.rciSplitWeekConfig=new RCISplitWeekConfig();
	}

	public String addRCISplitWeekConfigAction(){
		return navCommonOutcome(true);
	}
	public void addRCISplitWeekConfigActionListener(ActionEvent event){
		this.catchError=false;
		try{
			this.rciSplitWeekConfig.setCheckInDayName( DateUtil.getDayName(this.rciSplitWeekConfig.getCheckInDay() ));
			int nextCheckOutDay  = this.rciSplitWeekConfig.getCheckInDay() + this.rciSplitWeekConfig.getNoOfNight()-1;
			this.rciSplitWeekConfig.setCheckOutDay(nextCheckOutDay);
			this.rciSplitWeekConfig.setCheckOutDayName(DateUtil.getDayName(this.rciSplitWeekConfig.getCheckOutDay()));
			this.rciSplitWeekConfig.setCreatedBy(getThisUser());
			this.rciSplitWeekConfig.setCreatedDate(new Date());
			this.rciSplitWeekConfig.setIsDeleted(CommonConstant.NOT_DELETED);
			this.adminRCIService.saveRCISplitWeekConfig(rciSplitWeekConfig);
			this.rciSplitWeekConfigList=this.adminRCIService.getRCISplitWeekConfigList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navUpdateRCISplitWeekConfigAction(){
		return navCommonOutcome(false);
	}
	public void navUpdateRCISplitWeekConfigActionListener(ActionEvent event){
		UIParameter param=(UIParameter)event.getComponent().findComponent("rciSplitWeekConfigId");
		String rciSplitWeekConfigId = param.getValue().toString();
		
		for (RCISplitWeekConfig rciSplitWeekConfigP : this.rciSplitWeekConfigList){
			if (rciSplitWeekConfigP.getRciSplitWeekConfigId().equalsIgnoreCase(rciSplitWeekConfigId)){
				this.rciSplitWeekConfig = rciSplitWeekConfigP;
				break;
			}
		}
	}
	
	public String updateRCISplitWeekConfigAction(){
		return navCommonOutcome(true);
	}
	public void updateRCISplitWeekConfigActionListener(ActionEvent event){
		this.catchError=false;
		try{
			this.rciSplitWeekConfig.setCheckInDayName( DateUtil.getDayName(this.rciSplitWeekConfig.getCheckInDay() ));
			int nextCheckOutDay  = this.rciSplitWeekConfig.getCheckInDay() + this.rciSplitWeekConfig.getNoOfNight()-1;
			this.rciSplitWeekConfig.setCheckOutDay(nextCheckOutDay);
			this.rciSplitWeekConfig.setCheckOutDayName(DateUtil.getDayName(this.rciSplitWeekConfig.getCheckOutDay()));
			
			this.rciSplitWeekConfig.setModifiedBy(getThisUser());
			this.rciSplitWeekConfig.setModifiedDate(new Date());
			this.adminRCIService.updateRCISplitWeekConfig(rciSplitWeekConfig);
			this.rciSplitWeekConfigList=this.adminRCIService.getRCISplitWeekConfigList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String deleteRCISplitWeekConfigAction(){
		return navCommonOutcome(true);
	}
	public void deleteRCISplitWeekConfigActionListener(ActionEvent event){
		this.catchError=false;
		
		try{
			this.rciSplitWeekConfigDeleteList = new ArrayList<RCISplitWeekConfig>();
			for(RCISplitWeekConfig rciSplitWeekConfigP : this.rciSplitWeekConfigList){
				if (rciSplitWeekConfigP.isMarkAsSelect())
					this.rciSplitWeekConfigDeleteList.add(rciSplitWeekConfigP);
			}
			this.adminRCIService.deleteRCISplitWeekConfig(rciSplitWeekConfigDeleteList, getThisUser());
			this.rciSplitWeekConfigList=this.adminRCIService.getRCISplitWeekConfigList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
		
	}
	//-------------------------------------------------------------------------
	
	//----------RCI Booking Entry -----------------------//
	private RCIBookingEntry rciBookingEntry;
	private List<RCIBookingEntry> rciBookingEntryList;
	private List<RCIBookingEntry> rciBookingEntryDeleteList;
	private String actionNo;
	private List<SelectItem> selectRCIType;
	private List<SelectItem> selectRCIMembers;
	private List<SelectItem> selectRCISplitWeeks;
	private boolean incomingMember;
	
	
	public boolean isIncomingMember() {
		String rciTypeLocal = "";
		if (rciBookingEntry.getRciType()!=null)
			rciTypeLocal = rciBookingEntry.getRciType();
		if (rciTypeLocal.equalsIgnoreCase(BookingConstant.RCI_TYPE_INCOMING))
			incomingMember=true;	
		else
			incomingMember=false;	
		
		return incomingMember;
	}
	public List<SelectItem> getSelectRCISplitWeeks() {
		return selectRCISplitWeeks;
	}
	public RCIBookingEntry getRciBookingEntry() {
		return rciBookingEntry;
	}
	public void setRciBookingEntry(RCIBookingEntry rciBookingEntry) {
		this.rciBookingEntry = rciBookingEntry;
	}
	public List<RCIBookingEntry> getRciBookingEntryList() {
		return rciBookingEntryList;
	}
	public List<SelectItem> getSelectRCIType() {
		return selectRCIType;
	}
	public String initRCIBookingEntryAction(){
		return navCommonOutcome(false);
	}
	public void initRCIBookingEntryActionListener(ActionEvent event){
		try{
			this.rciBookingEntryList=this.adminRCIService.getRCIBookingEntryList();
			this.selectRCIType = new ArrayList<SelectItem>();
			this.selectRCIType.add(new SelectItem(BookingConstant.RCI_TYPE_INCOMING,BookingConstant.RCI_TYPE_INCOMING));
			this.selectRCIType.add(new SelectItem(BookingConstant.RCI_TYPE_OUTGOING,BookingConstant.RCI_TYPE_OUTGOING));
			
			this.selectRCISplitWeeks=new ArrayList<SelectItem>();
			List<RCISplitWeekConfig> splitWeekList = this.adminRCIService.getRCISplitWeekConfigList();
			for(RCISplitWeekConfig splitWeekConfig : splitWeekList){
				selectRCISplitWeeks.add(new SelectItem(splitWeekConfig.getRciSplitWeekConfigId(),splitWeekConfig.getRciSplitWeekDesc()));
			}
			
			this.selectRCIBulkBankList = new ArrayList<SelectItem>();
			List<RCIBulkBank> bulkBanlDepositList = this.adminRCIService.getRCIBulkBankAvList();//.getRCIBulkBankList();
			for(RCIBulkBank r : bulkBanlDepositList){
				
				this.selectRCIBulkBankList.add(new SelectItem(r.getRciBulkBankId(),
						r.getPartnerProduct().getPartner().getCompName()+" | "+ r.getPartnerProduct().getCode()+" | "+r.getPartnerProduct().getDesc()
						+" | Year "+ r.getYear()+" | Week "+ r.getWeek()+" | Room No.: "+r.getRoom1No()));
				
				/*this.selectRCIBulkBankList.add(new SelectItem(bulkBank.getRciBulkBankId(),
						bulkBank.getPartnerProduct().getCode()+" | "+bulkBank.getPartnerProduct().getDesc()
						+" | Week "+ bulkBank.getWeek()+" | Room No.: "+bulkBank.getRoom1No()));*/
			}
			
			
		}catch(BaseException be){
			initErrorBean(be);
		}
	}
	
	public String navAddRCIBookingEntryAction(){
		return navCommonOutcome(true);
	}
	public void navAddRCIBookingEntryActionListener(ActionEvent event){
		this.rciBookingEntry=new RCIBookingEntry();
		this.rciBookingEntry.setRciBulkBank(new RCIBulkBank());
		this.rciBookingEntry.setRciSplitWeekConfig(new RCISplitWeekConfig());
	}
	public List<SelectItem> getSelectRCIMembers() {
		
		try{
			selectRCIMembers = new ArrayList<SelectItem>();
			
			String rciTypeL = "";
			if (this.rciBookingEntry.getRciType()!=null)
				rciTypeL = this.rciBookingEntry.getRciType();
			if (rciTypeL.equalsIgnoreCase(BookingConstant.RCI_TYPE_INCOMING)){
				List<RCIIncomingMember> rciIncomingMemberList=this.adminRCIService.getRCIIncomingMemberList();
				for(RCIIncomingMember r : rciIncomingMemberList){
					selectRCIMembers.add(new SelectItem(r.getRciIncomingMemberId(),r.getFullName()+" ("+r.getIcPassportNo()+")"));
				}
			}else{
				List<RCIMember> rciMemberList = this.adminRCIService.getRCIMemberList();
				for (RCIMember r : rciMemberList){
					selectRCIMembers.add(new SelectItem(r.getRciMemberId(),r.getRciMemberName()+" ("+r.getMember().getMembershipNo()+")"));
				}
			}
		}catch(BaseException be){
			
		}
		
		return selectRCIMembers;
	}
	
	
	public String addRCIBookingEntryAction(){
		return navCommonOutcome(true);
	}
	public void addRCIBookingEntryActionListener(ActionEvent event){
		this.catchError=false;
		try{
			this.rciBookingEntry.setRciType(BookingConstant.RCI_TYPE_INCOMING);
			this.rciBookingEntry.setCreatedBy(getThisUser());
			this.rciBookingEntry.setCreatedDate(new Date());
			this.rciBookingEntry.setStatus(BookingConstant.STATUS_PENDING);
			this.rciBookingEntry.setIsDeleted(CommonConstant.NOT_DELETED);
			
			this.adminRCIService.saveRCIBookingEntry(rciBookingEntry);
			
			this.rciBookingEntryList=this.adminRCIService.getRCIBookingEntryList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navUpdateRCIBookingEntryAction(){
		return navCommonOutcome(true);
	}
	public void navUpdateRCIBookingEntryActionEvent(ActionEvent event){
		UIParameter param=(UIParameter)event.getComponent().findComponent("rciBookingEntryId");
		String rciBookingEntryId = param.getValue().toString();
		
		for(RCIBookingEntry rciBookingEntryP : this.rciBookingEntryList){
			if (rciBookingEntryP.getRciBookingEntryId().equalsIgnoreCase(rciBookingEntryId)){
				this.rciBookingEntry=rciBookingEntryP;
				break;
			}
		}
	}
	
	public String updateRCIBookingEntryAction(){
		return navCommonOutcome(true);
	}
	public void updateRCIBookingEntryActionListener(ActionEvent event){
		this.catchError=false;
		try{
			this.rciBookingEntry.setModifiedBy(getThisUser());
			this.rciBookingEntry.setModifiedDate(new Date());
			
			this.adminRCIService.updateRCIBookingEntry(rciBookingEntry);
			this.rciBookingEntryList=this.adminRCIService.getRCIBookingEntryList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String deleteRCIBookingEntryAction(){
		return navCommonOutcome(true);
	}
	public void deleteRCIBookingEntryActionListener(ActionEvent event){
		this.catchError=false;
		try{
			this.rciBookingEntryDeleteList=new ArrayList<RCIBookingEntry>();
			for (RCIBookingEntry rciBookingEntryP : this.rciBookingEntryList){
				if (rciBookingEntryP.isMarkAsSelect())
					this.rciBookingEntryDeleteList.add(rciBookingEntryP);
			}
			this.adminRCIService.deleteRCIBookingEntry(rciBookingEntryDeleteList, getThisUser());
			this.rciBookingEntryList=this.adminRCIService.getRCIBookingEntryList();
			
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navRCIBookingEntryApprovalAction(String actionNoP,String... params){
		this.actionNo = actionNoP;
		String rciBookingEntryId = params[1];
		
		try{
			this.rciBookingEntry = this.adminRCIService.getRCIBookingEntry(rciBookingEntryId);
		}catch(BaseException be){
			initErrorBean(be);
		}
		return NAV_VIEW_RCI_BOOKING_ENTRY.concat("_"+getRoleName());
	}
	
	public String approvalRCIBookingEntryAction(){
		return backToPartnerPortal();
	}
	public void approveRCIBookingEntryActionListener(ActionEvent event){
		try{
			this.adminRCIService.approveRCIBookingEntry(this.rciBookingEntry, this.actionNo, getThisUser());
		}catch(BaseException be){
			initErrorBean(be);
		}
	}
	public void rejectRCIBookingEntryActionListener(ActionEvent event){
		try{
			this.adminRCIService.rejectRCIBookingEntry(this.rciBookingEntry, this.actionNo, getThisUser());
		}catch(BaseException be){
			initErrorBean(be);
		}
	}
	public String backToPartnerPortal(){
		String outcome="partnerPortal";
		return outcome;
	}
	//---------------------------------------------------//
	//----RCI Member Deposit-----------------------------//
	private String rciBulkBankId;
	
	
	public String getRciBulkBankId() {
		return rciBulkBankId;
	}
	public void setRciBulkBankId(String rciBulkBankId) {
		this.rciBulkBankId = rciBulkBankId;
	}
	public String initRCIMemberDepositAction(){
		return navCommonOutcome(false);
	}
	public void initRCIMemberDepositActionListener(ActionEvent event){
		try{
			
			this.rciBulkBankList = this.adminRCIService.getRCIBulkBankOutgoingList();
			
			this.selectRCIBulkBankList = new ArrayList<SelectItem>();
			List<RCIBulkBank> availableList = this.adminRCIService.getRCIBulkBankAvList();
			for (RCIBulkBank r : availableList){
				this.selectRCIBulkBankList.add(new SelectItem(r.getRciBulkBankId(),
						r.getPartnerProduct().getPartner().getCompName()+" | "+ r.getPartnerProduct().getCode()+" | "+r.getPartnerProduct().getDesc()
						+" | Year "+ r.getYear()+" | Week "+ r.getWeek()+" | Room No.: "+r.getRoom1No()));
			}
			
			this.selectRCIMemberList=new ArrayList<SelectItem>();
			this.rciMemberList=this.adminRCIService.getRCIMemberList();
			for(RCIMember rciMemberP : this.rciMemberList){
				SelectItem selectItem=new SelectItem(rciMemberP.getRciMemberId(),rciMemberP.getRciNo());
				this.selectRCIMemberList.add(selectItem);
			}
		}catch(BaseException be){
			initErrorBean(be);
		}
	}
	
	public String navAddRCIMemberDepositAction(){
		return navCommonOutcome(false);
	}
	public void navAddRCIMemberDepositActionListener(ActionEvent event){
		this.rciBulkBank=new RCIBulkBank();
		this.rciMember = new RCIMember();
	}
	
	public String addRCIMemberDepositAction(){
		return navCommonOutcome(true);
	}
	public void addRCIMemberDepositActionListener(ActionEvent event){
		this.catchError=false;
		try{
			//UIParameter param=(UIParameter)event.getComponent().findComponent("rciBulkBankId");
			//String rciBulkBankId = param.getValue().toString();
			
			this.rciBulkBank = this.adminRCIService.getRCIBulkBank(rciBulkBankId);
			
		/*	for(RCIBulkBank r : this.rciBulkBankList){
				if (r.getRciBulkBankId().equalsIgnoreCase(rciBulkBankId)){
					this.rciBulkBank = r;
					break;
				}
			}*/
			
			System.out.println("PartnerProduct()="+rciBulkBank.getPartnerProduct());
			this.rciBulkBank.setReservedType(BookingConstant.RCI_TYPE_OUTGOING);
			this.rciBulkBank.setRefId(this.rciMember.getRciMemberId());
			this.rciBulkBank.setAvailableFlag(new Integer(0));
			
			this.adminRCIService.updateRCIBulkBank(this.rciBulkBank);
			
			this.rciBulkBankList = this.adminRCIService.getRCIBulkBankOutgoingList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navUpdateRCIMemberDepositAction(){
		return navCommonOutcome(false);
	}
	public void navUpdateRCIMemberDepositActionListener(ActionEvent event){
		UIParameter param=(UIParameter)event.getComponent().findComponent("rciBulkBankId");
		String rciBulkBankId = param.getValue().toString();
		
		for(RCIBulkBank r : this.rciBulkBankList){
			if (r.getRciBulkBankId().equalsIgnoreCase(rciBulkBankId)){
				this.rciBulkBank = r;
				break;
			}
		}
	}
	
	public String updateRCIMemberDepositAction(){
		return navCommonOutcome(true);
	}
	public void updateRCIMemberDepositActionListener(ActionEvent event){
		
	}
	
	public String removeRCIMemberDepositAction(){
		return navCommonOutcome(true);
	}
	public void removeRCIMemberDepositActionListener(ActionEvent event){
		
	}
	//---------------------------------------------------//
}
